import {createAction, createThunkAction} from "../../lib/redux-utils";
import {get, postForm, postJson} from "../../lib/http";
import {getPrincipal} from "../../lib/identity";

const principal = getPrincipal();
export const showCreate = createAction("LINE.SHOW_CREATE");
export const hideCreate = createAction("LINE.HIDE_CREATE");
export const updateModel = createAction("LINE.UPDATE");

export const query = createThunkAction("LINE.QUERY", params =>
    postJson("/line/getAll", params)
);
export const search = createThunkAction("LINE.SEARCH", params =>
    postJson("/line/search", params)
);
export const create = createThunkAction("LINE.CREATE", params =>
    postJson("/line/create", params)
);
export const del = createThunkAction("", params =>
    get("/line/del/" + params + "/" + principal.id)
);
export const importLine = createThunkAction("LINE.IMPORT", params =>
    postForm("/line/import/" + params.opId, params)
);

